import Setting from '@/setting';
var storage = {
    /**
     * @description 存储 localStorage 值
     * @param {String} name localStorage name
     * @param {String} value localStorage value
     * @param {Object} cookieSetting localStorage setting
     */
    set(key, value) {
        localStorage.setItem(`${Setting.storage}-${key}`, JSON.stringify(value));
    },

    /**
     * @description 拿到 localStorage 值
     * @param {String} name localStorage name
     */
    get(key) {
        return JSON.parse(localStorage.getItem(`${Setting.storage}-${key}`));
    },

    /**
     * @description 删除 localStorage
     * @param {String} name localStorage name
     */
    remove(key) {
        localStorage.removeItem(`${Setting.storage}-${key}`);
    },

    /**
     * @description 清除 localStorage
     */
     clear() {
        localStorage.clear();
    }
}

// 暴露给外部访问
export default storage;
